;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2022 singpolyma <singpolyma@singpolyma.net>
;;;
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guixrus packages difftastic)
  #:use-module (guix build-system cargo)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (gnu packages crates-io)
  #:use-module (gnu packages crates-graphics)
  #:use-module ((guixrus packages common rust) #:prefix rus:)
  #:use-module ((guixrus packages tree-sitter) #:prefix rus:))

(define-public difftastic
  (package
    (name "difftastic")
    (version "0.27.0")
    (source (origin
              (method url-fetch)
              (uri (crate-uri "difftastic" version))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "189sf9ar8hgc50bfhlji8mfbvdfs7k1mg70i72abdw6rm4f1dy5z"))))
    (build-system cargo-build-system)
    (arguments
     (list #:phases
           #~(modify-phases %standard-phases
               (add-after 'unpack 'allow-older-rayon
                 (lambda _
                   (substitute* "Cargo.toml"
                     (("1.5.2")
                      "1.5.1")))))
           #:cargo-inputs
           `(("rust-atty" ,rust-atty-0.2)
             ("rust-cc" ,rust-cc-1)
             ("rust-clap" ,rus:rust-clap-3)
             ("rust-const-format" ,rus:rust-const-format-0.2)
             ("rust-itertools" ,rust-itertools-0.10)
             ("rust-lazy-static" ,rust-lazy-static-1)
             ("rust-libc" ,rust-libc-0.2)
             ("rust-log" ,rust-log-0.4)
             ("rust-mimalloc" ,rus:rust-mimalloc-0.1)
             ("rust-owo-colors" ,rus:rust-owo-colors-3)
             ("rust-pretty-env-logger" ,rust-pretty-env-logger-0.4)
             ("rust-radix-heap" ,rus:rust-radix-heap-0.4)
             ("rust-rayon" ,rust-rayon-1)
             ("rust-regex" ,rust-regex-1)
             ("rust-rpds" ,rus:rust-rpds-0.10)
             ("rust-rustc-hash" ,rust-rustc-hash-1)
             ("rust-strsim" ,rust-strsim-0.10)
             ("rust-term-size" ,rust-term-size-0.3)
             ("rust-tree-sitter" ,rus:rust-tree-sitter-0.20)
             ("rust-typed-arena" ,rust-typed-arena-2)
             ("rust-walkdir" ,rust-walkdir-2)
             ("rust-wu-diff" ,rus:rust-wu-diff-0.1))
           #:cargo-development-inputs
           `(("rust-pretty-assertions" ,rust-pretty-assertions-1))))
    (home-page "http://difftastic.wilfred.me.uk/")
    (synopsis "Diff that understands syntax")
    (description
     "This package provides a @code{diff}-like program that
understands the syntax of source code files.")
    (license license:expat)))
